package chapter14;

import java.util.Arrays;
import java.util.Collections;
import java.util.List;

/**
 * @author : DuJiabao
 * @Date : 2021/2/25 10:30
 * @Project : thinking_in_java
 * @File : null.java
 * @Desc :
 */
public class LiteralPetCreator extends PetCreator {
  // 用于保存所有Class对象
  public static final List<Class<? extends Pet>> allTypes =
          Collections.unmodifiableList(Arrays.asList(
                  Pet.class, Dog.class, Cat.class, Mutt.class, Pug.class, EgyptianMau.class, Manx.class, Cymric.class
          ));
  // 从Mutt开始到末尾
  private static final List<Class<? extends Pet>> types = allTypes.subList(allTypes.indexOf(Mutt.class), allTypes.size());

  @Override
  public List<Class<? extends Pet>> types() {
    return types;
  }

  public static void main(String[] args) {
    System.out.println(types);  // [class chapter14.Mutt, class chapter14.Pug, class chapter14.EgyptianMau, class chapter14.Manx, class chapter14.Cymric]
  }
}